<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<h:panelGrid width="80%" columns="2"
		columnClasses="introCol1,introCol2">
		<h:outputText value="#{messages['txt.presentation_no']}" rendered="#{readonly}" />
		<h:inputText value="#{operationPermitHelper.permit.id}" readonly="true" rendered="#{readonly}" />

		<h:outputText value="#{messages['permit.partyid']}" />
		<h:panelGroup>
			<h:panelGroup rendered="#{not readonly}">
				<h:panelGroup id="identGroup">
					<h:inputText value="#{operationPermitHelper.partyNationalIdentity}"
						style="width:70%" readonly="true">
					</h:inputText>
					<h:inputHidden id="partyId" label="#{messages['permit.partyid']}"
						value="#{operationPermitHelper.partyNationalIdentity}"
						required="true" />
				</h:panelGroup>
				#{'   '}
				<a4j:commandLink ajaxSingle="true"
					oncomplete="#{rich:component('selectPartyPanel')}.show()">
					<f:setPropertyActionListener
						target="#{personHelper.returnValueField}"
						value="operationPermitHelper.party" />
					<f:setPropertyActionListener
						target="#{personHelper.reRenderComponents}"
						value="identGroup, partyGroup" />
					<f:setPropertyActionListener
						target="#{legalPersonHelper.returnValueField}"
						value="operationPermitHelper.party" />
					<f:setPropertyActionListener
						target="#{legalPersonHelper.reRenderComponents}"
						value="identGroup, partyGroup" />
					<h:outputText value="#{messages['intro.search']}" />
				</a4j:commandLink>
				<br />
				<rich:message style="color:Red;" for="partyId" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText value="#{operationPermitHelper.partyNationalIdentity}"
					style="width:70%" readonly="true">
				</h:inputText>
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="#{messages['permit.party_full_name']}:" />
		<h:panelGroup id="partyGroup">
			<a4j:region renderRegionOnly="true">
				<h:inputText id="partyName"
					value="#{operationPermitHelper.partyName}" readonly="true"
					style="width:100%;">
				</h:inputText>
			</a4j:region>
		</h:panelGroup>

		<h:outputText value="#{messages['permit.type']}" />
		<h:panelGroup>
			<h:panelGroup rendered="#{not readonly}">
				<h:selectOneMenu id="permitType" label="#{messages['permit.type']}"
					value="#{operationPermitHelper.permit.type}"
					converter="#{uiConverters.operationPermitType}" required="true">
					<f:selectItems value="#{uiConverters.operationPermitType.valueList}" />
				</h:selectOneMenu>
				<br />
				<rich:message style="color:Red;" for="permitType" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText
					value="#{messages[operationPermitHelper.permit.type.name()]}"
					style="width:100%;"
					readonly="true">
				</h:inputText>
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="#{messages['permit.validity_from']}" />
		<h:panelGroup>
			<h:panelGroup rendered="#{not readonly}">
				<rich:calendar id="validityFrom"
					label="#{messages['permit.validity_from']}"
					value="#{operationPermitHelper.permit.validityFrom}" required="true">
				</rich:calendar>
				<br />
				<rich:message style="color:Red;" for="validityFrom" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText value="#{operationPermitHelper.permit.validityFrom}" readonly="true" style="width:70%;"/>
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="#{messages['permit.validity_to']}" />
		<h:panelGroup>
			<h:panelGroup rendered="#{not readonly}">
				<rich:calendar value="#{operationPermitHelper.permit.validityTo}" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText value="#{operationPermitHelper.permit.validityTo}" readonly="true" style="width:70%;"/>
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="#{messages['operation_permit.permit_zone']}" />
		<h:panelGroup>
			<h:panelGroup rendered="#{not readonly}">
				<h:panelGroup id="selectedParcelGrp">
					<h:inputText id="selectedParcel"
						value="#{operationPermitHelper.selectedZoneName != null ? operationPermitHelper.selectedZoneName : messages['operation_permit.permit_zone_select']}"
						style="width:70%" readonly="true">
					</h:inputText>
					<h:inputHidden id="selectedZoneName"
						label="#{messages['operation_permit.permit_zone']}"
						value="#{operationPermitHelper.selectedZoneName}" required="true" />
				</h:panelGroup>
				#{'   '}
				<a4j:commandLink ajaxSingle="true"
					oncomplete="#{rich:component('selectZonePanel')}.show();">
					<h:outputText value="#{messages['intro.search']}" />
				</a4j:commandLink>
				<br />
				<rich:message style="color:Red;" for="selectedZoneName" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText
					value="#{operationPermitHelper.selectedZoneName != null ? operationPermitHelper.selectedZoneName : ''}"
					style="width:100%"
					readonly="true">
				</h:inputText>
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="#{messages['operation_permit.business_type']}" />
		<h:panelGroup id="businessTypeGrp">
			<h:panelGroup rendered="#{not readonly}">
				<h:inputText id="businessType"
					value="#{operationPermitHelper.permit.businessType != null ? operationPermitHelper.permit.businessType.name : ''}"
					style="width:70%" readonly="true">
				</h:inputText>
				#{'   '}
				<a4j:commandLink ajaxSingle="true"
					oncomplete="#{rich:component('selectBusinessTypePanel')}.show()">
					<f:setPropertyActionListener
						target="#{businessTypeHelper.returnValueField}"
						value="operationPermitHelper.permit.businessType" />
					<f:setPropertyActionListener
						target="#{businessTypeHelper.reRenderComponents}"
						value="businessType" />
					<h:outputText value="#{messages['intro.search']}" />
				</a4j:commandLink>
				<br />
				<rich:message style="color:Red;" for="businessType" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText
					value="#{operationPermitHelper.permit.businessType != null ? operationPermitHelper.permit.businessType.name : ''}"
					style="width:100%" readonly="true">
				</h:inputText>
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="#{messages['permit.request_text']}:" />
		<h:panelGroup>
			<a4j:region renderRegionOnly="true">
				<h:inputTextarea id="requestText"
					value="#{operationPermitHelper.permit.requestText}" required="true"
					label="#{messages['permit.request_text']}" rows="5"
					style="width:100%" validatorMessage="Valor muy corto" readonly="#{readonly}">
					<f:validateLength minimum="3" />
					<a4j:support event="onblur" />
				</h:inputTextarea>
				<br />
				<rich:message style="color:Red;" for="requestText" />
			</a4j:region>
		</h:panelGroup>
	</h:panelGrid>

</ui:composition>
